<template>
    <div class="qingwu">
        <div class="admin_table_page_title">报警记录</div>
        <div class="unline underm"></div>

        <estate-search :searchConfig="searchConfig" @searchParams="search"></estate-search>

        <div class="admin_table_list">
            <a-table :columns="columns" :data-source="list" :pagination="false">

                <span slot="device_type" slot-scope="rows">
                    <div class="admin_goods_pic_txt">
                        <div>{{rows.is_failure == 1 ? '未解除' : '已解除'}}</div>
                    </div>
                </span>

                <span slot="room_number" slot-scope="rows">
                    <div class="admin_goods_pic_txt">
                        <div>{{rows.user && rows.user.room_number ? rows.user.room_number :'未绑定房间'}}</div>
                    </div>
                </span>


            </a-table>
            <div class="admin_pagination" v-if="total>0">
                <a-pagination v-model="params.page" :page-size.sync="params.limit" :total="total" @change="onChange" show-less-items/>
            </div>
        </div>
    </div>
</template>

<script>
    import estateSearch from '@/components/estate/search'

    export default {
        components: {estateSearch},
        props: {},
        data() {
            return {
                params: {
                    page: 1,
                    limit: 30,
                },
                total: 0, //总页数
                searchConfig: [
                    {label: '手机号', name: 'mobile', type: 'text'},
                ],
                selectedRowKeys: [], // 被选择的行
                columns: [
                    {title: '房间号', scopedSlots: {customRender: 'room_number'}},
                    {title: '业主', dataIndex: 'user.username'},
                    {title: '表地址', dataIndex: 'code'},
                    {title: '电话', dataIndex: 'user.mobile'},
                    {title: '报警内容', dataIndex: 'content'},
                    {title: '报警类型', dataIndex: 'alarm_type'},
                    {title: '报警状态', scopedSlots: {customRender: 'device_type'}},
                    {title: '报警时间', dataIndex: 'create_time'}
                ],
                list: []
            };
        },
        watch: {},
        computed: {},
        methods: {
            // 选择分页
            onChange(e) {
                this.params.page = e;
                this.onload();
            },
            onload() {
                this.$get(this.$api.alarmRecord, this.params).then(res => {
                    this.total = res.data.total;
                    this.list = res.data.data;
                });
            },
            // 重置
            reset() {
                location.reload();
            },
            // 搜索
            search(params) {
                let page = this.params.page;
                let per_page = this.params.limit;
                this.params = params;
                this.params.page = page;
                this.params.limit = per_page;
                this.onload();
            },
        },
        created() {
            this.onload();
        },
        mounted() {
        }
    };
</script>
<style lang="scss" scoped>

</style>
